package com.huabo.cybermonitor;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;


/**
 * @author kangjx
 * @createTime 2022/7/13
 */
//@SpringBootTest
public class GeneratorMp {

    @Test
    public void testCreate(){
        FastAutoGenerator.create("jdbc:oracle:thin:@60.205.166.36:1521:orcl", "HBGRCTEST", "HBGRCTEST")
                .globalConfig(builder -> {
                    builder.author("kangjx") // 设置作者
//                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("~\\generator"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.huabo.cybermonitor"); // 设置父包名
//                            .moduleName("person"); // 设置父包模块名
//                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "D://")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("TBL_ORGANIZATION",//组织机构
                            "TBL_FORM_ATT","TBL_FORM_CONTROELE","TBL_FORM_CONTROLLOG","TBL_FORM_CONTROLRULE","TBL_FORM_ELEMENTS"
                            ,"TBL_FORM_EVENT","TBL_FORM_INFO","TBL_FORM_MODEL","TBL_FORM_MODEL_ITEM","TBL_FORM_VALUE" //表单所有表
                            ,"TBL_INDICATOR","TBL_INDICATOR_CM","TBL_INDICATOR_FLOW","TBL_INDICATOR_RISKEVENT","TBL_INDICATORPREWARNING","TBL_INDICATORSYSTEM"
                            ,"TBL_INDICATORTHRESHOLD" //指标表
                    ) //设置需要生成的表名
                            .addTablePrefix("TBL_"); // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }

}
